﻿using System.Collections.Generic;
using System.Xml.Serialization;

namespace NielsHebling.UnitTestResultViewerForSL.Core.Data
{
    [XmlRoot("StatLightTestResults")]
    public class Result
    {
        [XmlAttribute("xapFileName")]
        public string XapFileName { get; set; }

        [XmlAttribute("total")]
        public int TestsTotal { get; set; }

        [XmlAttribute("failed")]
        public int TestsFailed { get; set; }

        [XmlAttribute("ignored")]
        public int TestsIgnored { get; set; }

        [XmlAttribute("dateRun")]
        public string DateRun { get; set; }

        [XmlElement("tests")]
        public List<Tests> TestResults { get; set; }

        public Result()
        {
            TestResults = new List<Tests>();
        }
    }

    public class Tests
    {
        [XmlElement("test")]
        public List<Test> Items { get; set; }

        public Tests()
        {
            Items = new List<Test>();
        }
    }

    public class Test
    {
        [XmlAttribute("name")]
        public string Method { get; set; }

        [XmlAttribute("resulttype")]
        public string Result { get; set; }

        [XmlAttribute("timeToComplete")]
        public string Duration { get; set; }

        [XmlElement("exceptionInfo")]
        public TestExceptionInfo ExceptionInfo { get; set; }

        public Test()
        {
            ExceptionInfo = new TestExceptionInfo();
        }
    }

    public class TestExceptionInfo
    {
        [XmlElement("message")]
        public string Message { get; set; }

        [XmlElement("stackTrace")]
        public string StackTrace { get; set; }
    }    
}
